//
//  KLDeflutAddressView.m
//  KunLun
//
//  Created by Mac on 2017/12/28.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "KLDeflutAddressView.h"
@interface KLDeflutAddressView()
@property(nonatomic, strong) STLabel                     *titleLable;
@property(nonatomic, strong) STLabel                     *phoneLable;

@end
@implementation KLDeflutAddressView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    self.backgroundColor = [UIColor whiteColor];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(15, 31, 200, 20)
                                                     text:@"----"
                                                textColor:KL_firstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    self.titleLable = titleLable;
    [self addSubview:self.titleLable];
    
    self.phoneLable = [[STLabel alloc] initWithFrame:CGRectMake(31, 31, 200, 20)
                                                     text:@"-------"
                                                textColor:KL_firstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentRight];
    self.phoneLable.right = UIScreenWidth - 15;
    [self addSubview:self.phoneLable];
    
    STButton * iconButton = [[STButton alloc] initWithFrame:CGRectMake(15, self.titleLable.bottom , 44, 44)
                                                     title:nil
                                                titleColor:nil
                                                 titleFont:0
                                              cornerRadius:0
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:[UIImage imageNamed:@"img_mine_addressEdit"]];
    iconButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [self addSubview:iconButton];
    
    STButton * indicationButton = [[STButton alloc] initWithFrame:CGRectMake(15, self.titleLable.bottom , 44, 44)
                                                      title:nil
                                                 titleColor:nil
                                                  titleFont:0
                                               cornerRadius:0
                                            backgroundColor:nil
                                            backgroundImage:nil
                                                      image:[UIImage imageNamed:@"我的--下拉"]];
    indicationButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    indicationButton.right = UIScreenWidth - 15;
    [self addSubview:indicationButton];
    
    self.desLable = [[STLabel alloc] initWithFrame:CGRectMake(iconButton.right, self.titleLable.bottom + 13, indicationButton.left - iconButton.right, 40)
                                                text:@"打飞机考虑是否打算考虑房价克里斯丁附近开了时代峰峻克里斯丁多少了房间"
                                           textColor:KL_firstTextColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    //self.desLable.centerY = iconButton.centerY;
    [self addSubview:self.desLable];
    
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, self.desLable.bottom, UIScreenWidth, 10)];
    view.backgroundColor = KL_backgroundColor;
    [self addSubview:view];
    self.height = view.bottom;
    
}
- (void)setModel:(STAddressModel *)model{
    _model = model;
    if (model) {
        self.titleLable.text = model.name;
        self.phoneLable.text = model.telephone;
        self.desLable.text = [NSString stringWithFormat:@"%@%@%@",model.province,model.city,model.address];
        [NSString lableAutoAdjustheightWithLabel:self.desLable];

    }else{
        self.desLable.text = @"暂无地址，请添加默认地址";
        [NSString lableAutoAdjustheightWithLabel:self.desLable];

    }

}
@end
